// 2.组合继承(经典继承)

Super.prototype.sayName = function() {
    console.log(this.name);
}

function Super(name) {
    this.name = name
    this.colors = ['red', 'blue']
}

Sub.prototype = new Super()
Sub.prototype.constructor = Sub


function Sub(name, age) {
    this.age = age
    Super.call(this, name)
} 

var instance = new Sub('123', 20)

// instance.colors = []

console.log(instance.name);

// 解决了原型链继承不能向父类传参的缺陷
// 解决了原型链继承的缺陷

// 缺点：
    // 父类的构造函数一定会调用两次